package com.stu.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class HelloController {
    //访问：http://localhost:8080/hello
    @RequestMapping("/hello")
    @ResponseBody
    public String hello(){
        return "Hello World!!!";
    }

    //访问：http://localhost:8080/test01?name=Bob
    @RequestMapping("/test01")
    @ResponseBody
    public String test01(String name){
        return "name="+name;
    }

    //访问：http://localhost:8080/test02/Bob
    @RequestMapping("/test02/{name}")
    @ResponseBody
    public String test02(@PathVariable String name){
        return "name="+name;
    }


    @RequestMapping("/test03")
    public String test03(){
        return "redirect:hello.html";
    }

    @RequestMapping("/test04")
    public String test04(){
        return "index";
    }
}